{% for suffix in ['', 'RFC'] -%}

select 'ipv4';
select port{{ suffix }}('http://127.0.0.1/');
select port{{ suffix }}('http://127.0.0.1:80');
select port{{ suffix }}('http://127.0.0.1:80/');
select port{{ suffix }}('//127.0.0.1:80/');
select port{{ suffix }}('127.0.0.1:80');

select 'hostname';
select port{{ suffix }}('http://foobar.com/');
select port{{ suffix }}('http://foobar.com:80');
select port{{ suffix }}('http://foobar.com:80/');
select port{{ suffix }}('//foobar.com:80/');
select port{{ suffix }}('foobar.com:80');

select 'default-port';
select port{{ suffix }}('http://127.0.0.1/', toUInt16(80));
select port{{ suffix }}('http://foobar.com/', toUInt16(80));

-- unsupported
/* ILLEGAL_TYPE_OF_ARGUMENT */ select port(toFixedString('', 1)); -- { serverError 43 }
/* ILLEGAL_TYPE_OF_ARGUMENT */ select port{{ suffix }}('', 1); -- { serverError 43 }
/* NUMBER_OF_ARGUMENTS_DOESNT_MATCH */ select port{{ suffix }}('', 1, 1); -- { serverError 42 }

--
-- Known limitations of domain() (getURLHost())
--
select 'ipv6';
select port{{ suffix }}('http://[2001:db8::8a2e:370:7334]/');
select port{{ suffix }}('http://[2001:db8::8a2e:370:7334]:80');
select port{{ suffix }}('http://[2001:db8::8a2e:370:7334]:80/');
select port{{ suffix }}('//[2001:db8::8a2e:370:7334]:80/');
select port{{ suffix }}('[2001:db8::8a2e:370:7334]:80');
select port{{ suffix }}('2001:db8::8a2e:370:7334:80');
select 'host-no-dot';
select port{{ suffix }}('//foobar:80/');

{%- endfor %}
